﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraBars;
using CTEM.ModuleForms.ManageEmployee;
using CTEM.Controllers.BUS;
using CTEM.Models;

namespace CTEM.ModuleForms.ManageReport
{
    public partial class EmployeeSalaryReportDetail : DevExpress.XtraBars.Ribbon.RibbonForm
    {
        public EmployeeSalaryReport _employeeSalaryReport;
        private List<EmployeeSalaryDTO> listEmployeeSalary;
        private EmployeeSalaryDTO employeeSalary;
        private List<EmployerDTO> listEmployee;

        public EmployeeSalaryReportDetail()
        {
            
            _employeeSalaryReport = new EmployeeSalaryReport();
            _employeeSalaryReport.Show();
            InitializeComponent();
            _employeeSalaryReport.AskInformationChanged += new EmployeeSalaryReport.InformationEmployeeDelegate(loadData);
        }



      
        public void loadData(EmployerDTO employee, DateTime fromTime, DateTime toTime)
        {
            EmployeeBUS empBUS = new EmployeeBUS();

            listEmployeeSalary = empBUS.LoadSalaryForReport(employee.employeeID,fromTime,toTime);
            xtra_EmployeeSalaryReport report = new xtra_EmployeeSalaryReport();
            report.DataBind(listEmployeeSalary, fromTime,  toTime,employee);

            printControl1.PrintingSystem = report.PrintingSystem;
            report.CreateDocument();
        }

        private void EmployeeSalaryReport_Load(object sender, EventArgs e)
        {
            
        }

        private void btChooseEmployee_ItemClick(object sender, ItemClickEventArgs e)
        {
            _employeeSalaryReport.Visible = true;
        }

        private void EmployeeSalaryReportDetail_FormClosing(object sender, FormClosingEventArgs e)
        {
            _employeeSalaryReport.Enabled = false;
        }
    }
}